#include "SoundManager.h"
#include <string>
using namespace std;
SoundManager::SoundManager()
{
	mResPath[BackgroundMusic] = string("Contents/BirdAndEagle/Sound/BackgroundMusic.wav");

	mResPath[BirdNormalMusic]= string("Contents/BirdAndEagle/Sound/BirdFlying.wav");
	mResPath[BirdLoseMusic] = string("Contents/BirdAndEagle/Sound/BirdCaughtScreech.wav");
	mResPath[BirdWinMusic] = string("Contents/BirdAndEagle/Sound/BirdCheerful.wav");
	mResPath[BirdTouchEagleOrWallMusic] = string("Contents/BirdAndEagle/Sound/BirdCollideScreech.wav");
	
	mResPath[EagleWinMusic] =string("Contents/BirdAndEagle/Sound/EagleCheerful.wav");
	mResPath[EagleLoseMusic] = string("Contents/BirdAndEagle/Sound/EagleFail.wav");
	mResPath[EagleNormalMusic] = string("Contents/BirdAndEagle/Sound/EagleFlying.wav");
}
SoundManager::~SoundManager()
{
	for (int i=0;i<MusicTotalCount;i++)
	{
		if (mAudioList[i])
		{
			delete mAudioList[i];
			mAudioList[i] = 0;
		}
	}
}
void SoundManager::Init()
{
	for (int i=0;i<MusicTotalCount;i++)
	{
		mAudioList.push_back(new QSound(mResPath[i].c_str()));
	}
}
void SoundManager::Play(SoundResource s)
{
	if (mAudioList[s]->isFinished())
	{
		mAudioList[s]->play();
	}
}
void SoundManager::Stop(SoundResource s)
{
	mAudioList[s]->stop();
}